package com.wen.statistics.schedule;

import com.wen.statistics.service.DailyService;
import com.wen.statistics.utils.DateUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @Author：Win
 * @Date: 2021/6/23 17:36
 * @Description: 每天定时执行统计数据
 */
@Component
public class ScheduleTask {
    @Resource
    private DailyService dailyService;

    /**
     * 每天凌晨1点执行操作
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void schedule() {
        Date date = DateUtil.addDays(new Date(), -1);
        String day = DateUtil.formatDate(date);
        dailyService.countRegister(day);
    }
}
